﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

/*
 * 
 * 
 * FINISHED!
 * 
 * 
 * 
 */

namespace MySQLLib
{
    public class Saved_skills
    {
        string[,] _saved_skills;
        private MySqlConnection conn;

        public void setConnection(MySqlConnection connection)
        {
            this.conn = connection;
        }

        public void refresh()
        {
            string[] column = new string[1];
            column[0] = "*";

            this._saved_skills = Query.SelectQuery(this.conn, "saved_skills", column);
        }


        public string[,] getSavedSkillsFromOwner(MySqlConnection conn, int owner)
        {
            string[,] result;
            string[] columns = new string[1];
            columns[0] = "*";

            result = Query.SelectQuery(conn, "saved_skills", columns, "owner=" + owner.ToString(), "id");

            return result;
        }

        public string[] getSkillDataAtRow(MySqlConnection conn, int id)
        {
            string[] result;

            result = Query.getRowData(conn, "saved_skills", id);

            return result;
        }

        public void addSavedSkill(MySqlConnection conn, int owner, int skillid, int level = 1)
        {
            string[] columns = new string[3];
            string[] values = new string[3];

            columns[0] = "owner";
            columns[1] = "skillid";
            columns[2] = "level";

            values[0] = owner.ToString();
            values[1] = skillid.ToString();
            values[2] = level.ToString();

            Query.InsertQuery(conn, "saved_skills", columns, values);
        }

        public string[,] Saved_Skills
        {
            get { return this._saved_skills; }
        }
    }
}
